//
//  ImageCell.m
//  ProjectForA
//
//  Created by 靖哥哥 on 14/11/20.
//  Copyright (c) 2014年 hmengwei. All rights reserved.
//

#import "ImageCell.h"
#import "RecommendModel.h"
#import "UIImageView+WebCache.h"

@implementation ImageCell

- (void)dealloc
{
    [_model release];
    [_Ima release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.Ima = [[UIImageView alloc] initWithFrame:self.bounds];
        _Ima.backgroundColor = [UIColor blueColor];
        _Ima.layer.cornerRadius = 10;
        _Ima.layer.masksToBounds = YES;
        [self addSubview:_Ima];
        [_Ima release];
        
        // KVO成对出现
        [self addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
    }
    return self;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        
        [self.Ima setImageWithURL:[NSURL URLWithString:self.model.photo]];
        
        
    }

}
@end
